﻿#include "ExampleApplication.h"
//#include <memory>
#include <vtkm/cont/DeviceAdapter.h>
#include <vtkm/cont/RuntimeDeviceTracker.h>

#include "Steady.h"

void ExampleApplication::Run()
{
  console::Info("ExampleApplication::Run");

  PrintLogo();
  //ParseCLI();

  CreateActions();

  SetupDevice();

  RunExecutioner();
}

void ExampleApplication::PrintLogo()
{
  std::cout << "ExampleApplication::PrintLogo， 计算区域面积" << std::endl;
}

void ExampleApplication::RunExecutioner()
{
  _executioner->Init();
  _executioner->Execute();
}

void ExampleApplication::CreateActions()
{
  Configuration cfg;
  cfg.Add<Application*>("_app", this);
  
  // Create System

  _executioner = std::make_shared<Steady>(cfg);
}

void ExampleApplication::SetupDevice()
{
  _device.reset(new vtkm::cont::DeviceAdapterTagSerial);

  auto& tracker = vtkm::cont::GetRuntimeDeviceTracker();
  if (!tracker.CanRunOn(*_device))
  {
    console::Error(
      "不能在 Device Tag: ", _device->GetName(), "上运行，", "选项：serial|cuda|tbb|openmp|hip");
  }

  console::Info("Device Tag: ", _device->GetName());
  tracker.ForceDevice(*_device);
}
